//==================================================================================================
//    TToolTip class
function TToolTip(){
    var self = this;
    this.isShown = 0;
    this.padding = Math.floor(Math.min(document.documentElement.clientHeight,document.documentElement.clientWidth)*0.01);
    this.toolTipContainer = document.createElement('div');
    this.toolTipContainer.onclick = function(event){event.stopPropagation();};
    this.toolTipContainer_style = this.toolTipContainer.style;
    this.toolTip = document.createElement('div');
    this.toolTip.style.display = 'inline-block';
    this.toolTip.style.zIndex = 'inherit';
    this.toolTip.style.verticalAlign = 'top';
    this.toolTipContainer.appendChild(this.toolTip);
    this.closeButton = document.createElement('div');
    this.closeButton.style.display = 'inline';
    this.closeButton.style.marginLeft = '10px';
    this.toolTipContainer.appendChild(this.closeButton);
    this.closeButton.innerHTML = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg width="15"   height="15"   id="svg2"   version="1.1">    <defs id="defs4"/>    <metadata     id="metadata7">        <rdf:RDF>            <cc:Work         rdf:about="">                <dc:format>image/svg+xml</dc:format>                <dc:type           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />                <dc:title></dc:title>                </cc:Work>                </rdf:RDF>    </metadata>    <g id="layer1" transform="scale(0.1)">        <rect style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd" id="rect2985" width="25.675293" height="165.70914" x="-21.096132" y="22.13365"   ry="0" rx="0" transform="matrix(0.60780759,-0.79408433,0.73836455,0.6744018,0,0)" />        <rect style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd" id="rect2986" width="25.377584" height="166.40895" x="93.352753"  y="-79.408836" ry="0" rx="0" transform="matrix(0.71283141,0.70133542,-0.71993304,0.69404353,0,0)"/>    </g></svg>';
    this.closeButton.style.zIndex = 'inherit';
    this.closeButton.style.display = 'inline-block';
    this.closeButton.style.border = this.border + 'px solid white';
    this.closeButton.style.verticalAlign = 'inherit';
    this.toolTipContainer_style.padding = this.padding + 'px';
    this.toolTipContainer_style.borderRadius = Math.floor(Math.min(document.documentElement.clientHeight,document.documentElement.clientWidth)/70) + 'px';
    this.border = 1;
    this.toolTipContainer_style.border = this.border + 'px solid black';
    this.toolTipContainer_style.display = 'block';
    this.toolTipContainer_style.zIndex = 3;
    this.toolTipContainer_style.position = 'absolute';
    this.toolTipContainer_style.visibility = 'hidden;';
    this.toolTipContainer_style.backgroundColor = 'white';
    this.toolTipContainer_style.verticalAlign = 'top';
    this.toolTipContainer_style.minWidth = (9*this.padding)+'px';
    this.toolTipContainer_style.minHeight = (4*this.padding)+'px';
    this.arrow = document.createElement('div');
    this.arrow.setAttribute('style', 'display: inline; position: absolute; background-color: white; border:' + this.border + 'px solid black; height:' + this.padding*4 + 'px; width: ' + this.padding*4 + 'px; visibility: hidden; -webkit-transform: matrix(1,-1,0,1,0,0); -moz-transform: matrix(1,-1,0,1,0,0); -o-transform: matrix(1,-1,0,1,0,0); -ms-transform: matrix(1,-1,0,1,0,0); z-index: 2;');
    this.false_arrow = document.createElement('div');
    this.false_arrow.style.height = 5*this.border+'px';
    this.false_arrow.style.width  = ( this.padding*3 -this.border) + 'px';
    this.false_arrow.style.backgroundColor = 'white';
    this.false_arrow.style.position        = 'inline';
    this.false_arrow.style.visibility      = 'hidden';
    this.false_arrow.style.position        = 'absolute';
    this.false_arrow.style.zIndex          = 5;
    this.parentWidget = 0;
    this.X=0;
    this.Y=0;
    this.showToolTip = function(X, Y, text, parentId){
        self.isShown = 1;
        self.X = X;
        self.Y = Y;
        self.toolTip.innerHTML = text;
        self.parentWidget = document.getElementById(parentId);
        self.parentWidget.appendChild(self.toolTipContainer);
        self.toolTipContainer_style.left = (X-self.padding*4)+'px';
        self.toolTipContainer_style.top  = ((Y-parseInt(window.getComputedStyle(self.toolTipContainer,'').height)-self.padding*2-self.border*2) - 3*self.padding)+'px';
        self.toolTipContainer_style.visibility = 'visible';
        self.parentWidget.appendChild(self.arrow);
        self.arrow.style.top =  ( Y - 6*self.padding )+'px';
        self.arrow.style.left = X+'px';
        self.arrow.style.visibility = 'visible';
        self.parentWidget.appendChild(self.false_arrow);
        self.false_arrow.style.top =  ( Y - 3*self.padding - 4*self.border )+'px';
        self.false_arrow.style.left = ( X + 2*self.border )+'px';
        self.false_arrow.style.visibility = 'visible';
    };
    this.showToolTipOnEvent = function(event, text, parentId){
        self.showToolTip(event.clientX, event.clientY, text, parentId);
    }
    this.hideToolTipOnEvent = function(event) {
        event.stopPropagation();
        self.hideToolTip();
    };
    this.hideToolTip = function() {
        if(self.isShown>0){
            self.X=0;
            self.Y=0;
            self.parentWidget.removeChild(self.toolTipContainer);
            self.parentWidget.removeChild(self.arrow);
            self.parentWidget.removeChild(self.false_arrow);
            self.isShown = 0;
        }
    };
    this.moveToolTipToNewPosition = function(X, Y){
        self.X = X;
        self.Y = Y;
        self.toolTipContainer_style.left = (X-self.padding*4)+'px';
        self.toolTipContainer_style.top  = ((Y-parseInt(window.getComputedStyle(self.toolTipContainer,'').height)-self.padding*2-self.border*2) - 3*self.padding)+'px';
        self.arrow.style.top =  ( Y - 6*self.padding )+'px';
        self.arrow.style.left = X+'px';
        self.false_arrow.style.top =  ( Y - 3*self.padding - 4*self.border )+'px';
        self.false_arrow.style.left = ( X + 2*self.border )+'px'
    };
    this.correctToolTipPositon = function(dX, dY){
        self.moveToolTipToNewPosition(self.X+dX, self.Y+dY);
    }
    this.closeButton.onclick = this.hideToolTipOnEvent;
};
//==================================================================================================
